-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Allow block time offset to be negative #663
Conversation
🦋 Changeset detectedLatest commit: fd26e31 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Yes, for bugs we always add a regression test, ideally on the EDR side, using typed method invocations. The integration test folder of the provider already has a bunch of examples. https://github.com/NomicFoundation/edr/tree/main/crates%2Fedr_provider%2Ftests%2Fissues |
Pushed a fix and added a regression test for this; verifying that the test fails without the fix and succeeds afterwards, so this should be ready for review now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the test. LGTM
Closes #588
This uses a simple approach of first converting to
i128
, which we know will be lossless, to only then fallibly convert it to a smaller type ofi64
.We do that for simplicity: one could convert a tuple of (sign, value) to shave some bytes and cycles but we would have to explicitly handle the case of
i64::MIN
(its absolute value is greater by 1 than i64::MAX), which would be a bit noisy, whereas not handling it and naively using aif sign { -1 } else { 1 } * i64::try_from(value)...
would not fully handle that edge case.I tested locally the reproduction steps from #588 and can both confirm that the error happens using the steps and the problem disappears after applying the fix here. Let me know if you feel that we should add a regression test and if so, how would you prefer to proceed with testing this.